package com.test;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;

import com.alibaba.dubbo.demo.Student;
import com.alibaba.dubbo.demo.Teacher;

import feign.Feign;
import feign.Request;
import feign.jackson.JacksonDecoder;
import feign.jackson.JacksonEncoder2;
import feign.okhttp.OkHttpClient;

public class GetDemo {

	public static void main(String[] args) {
		FeignService feignService = Feign.builder()
				.client(new OkHttpClient())
				.options(new Request.Options(200, TimeUnit.MILLISECONDS, 500, TimeUnit.MILLISECONDS, true))
				.encoder(new JacksonEncoder2())
				.decoder(new JacksonDecoder())
				.target(FeignService.class, "http://localhost:8083");
		// 接口在spring-webflux的com.demo.webflux.feigncore里
		List<Student> contributors = new ArrayList<>();
		//contributors = feignService.contributors("OpenFeign", 10);
		for (Student contributor : contributors) {
			System.out.println(contributor.getName() + " ("+ contributor.getAge() + ")");
		}
		Map headMap = new HashMap<>();
		headMap.put("token", "1123");
		headMap.put("auth", "aaa");
		headMap.put("clienttoken", "xzxa");
		Teacher teacher = new Teacher();
		teacher.setName("zsl");
		List<Student> contributors2 = feignService.contributors(headMap, teacher);
		for (Student contributor : contributors2) {
			System.out.println(contributor.getName() + " ("+ contributor.getAge() + ")");
		}
	}

}
